home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / JZFNDFST.C < prev    next >
Text File  |  1988-12-18  |  1KB  |  42 lines

  1. /*
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │Title     : jzfndfst                                 │
  4. │Purpose : find the first matching file from a given file spec             │
  5. │Notes:  You must define a directory record from the type TDIR, defined in   │
  6. │     in jzdirect.h                                 │
  7. │Parms:                                      │
  8. │   fmask - i.e. "*.*"                                                       │
  9. │   fattr - file attribute to use for search. use 32 for normal searches     │
  10. │   fdta  - TDIR variables                             │
  11. │                                         │
  12. │i.e.       error = jzfndfst ( "*.*" , 0x20 , &dir_record )                   │
  13. │Written by Jack Zucker - 75766,1336    301-794-5950  on 1/15/85         │
  14. └────────────────────────────────────────────────────────────────────────────┘
  15. */
  16. #include <jaz.h>
  17. #include <jzdirect.h>
  18. jzfndfst (fmask,fattr,fdta)
  19. char *fmask;
  20. int  fattr;
  21. TDIR *fdta;
  22. {
  23.  
  24.   TREG wreg;
  25.   int wdtaofs,wdtaseg;
  26.  
  27.   jzgetdta(&wdtaofs,&wdtaseg);        /* get old dta */
  28.  
  29.   jzsetdta(fdta);            /* set new dta */
  30.  
  31.   wreg.x.ds  = getds();
  32.   wreg.x.dx  = (int) fmask;
  33.   wreg.h.ah  = 0x4e;        /* find first matching file     */
  34.   wreg.x.cx  = fattr;        /* set file attribute for search */
  35.   msdos(&wreg);
  36.  
  37.   jzsetdta(wdtaofs);        /* conditionalize later for large model */
  38.  
  39.   if (wreg.x.flags & 0x0001) return(wreg.x.ax);
  40.   else return(0);    /* return 0 if no error, otherwise dos error code */
  41. }
  42.